export function getLastWeekArr() {
  var myDate = new Date() //获取系统当前时间
  var date1 = new Date(myDate.getTime() - 1 * 24 * 60 * 60 * 1000)
  var date2 = new Date(myDate.getTime() - 7 * 24 * 60 * 60 * 1000)
  var year1 = date1.getFullYear()
  var month1 = date1.getMonth() + 1 < 10 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1
  var day1 = date1.getDate() < 10 ? '0' + date1.getDate() : date1.getDate()
  var d1 = year1 + '-' + month1 + '-' + day1
  var year2 = date2.getFullYear()
  var month2 = date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1
  var day2 = date2.getDate() < 10 ? '0' + date2.getDate() : date2.getDate()
  var d2 = year2 + '-' + month2 + '-' + day2
  var dataObj = {}
  var dateArea = []
  dataObj.startdate = d2 + ' 00:00:00'
  dataObj.enddate = d1 + ' 23:59:59'
  dateArea[0] = d2 + ' 00:00:00'
  dateArea[1] = d1 + ' 23:59:59'
  return dateArea
}
export function getLastWeekObj() {
  var myDate = new Date() //获取系统当前时间
  var date1 = new Date(myDate.getTime() - 1 * 24 * 60 * 60 * 1000)
  var date2 = new Date(myDate.getTime() - 7 * 24 * 60 * 60 * 1000)
  var year1 = date1.getFullYear()
  var month1 = date1.getMonth() + 1 < 10 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1
  var day1 = date1.getDate() < 10 ? '0' + date1.getDate() : date1.getDate()
  var d1 = year1 + '-' + month1 + '-' + day1
  var year2 = date2.getFullYear()
  var month2 = date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1
  var day2 = date2.getDate() < 10 ? '0' + date2.getDate() : date2.getDate()
  var d2 = year2 + '-' + month2 + '-' + day2
  var dataObj = {}
  var dateArea = []
  dataObj.startdate = d2 + ' 00:00:00'
  dataObj.enddate = d1 + ' 23:59:59'
  dateArea[0] = d2 + ' 00:00:00'
  dateArea[1] = d1 + ' 23:59:59'
  return dataObj
}
// 下载文件
export function downloadFile(res, fileName) {
  let blob = new Blob([res]); //res为从后台返回的数据
  if (!fileName) {
    fileName = res.headers['content-disposition'].split('filename=').pop();
  }
  if ('msSaveOrOpenBlob' in navigator) {
    window.navigator.msSaveOrOpenBlob(blob, fileName);
  } else {
    const elink = document.createElement('a');
    elink.download = fileName;
    elink.style.display = 'none';
    elink.href = URL.createObjectURL(blob);
    document.body.appendChild(elink);
    elink.click();
    URL.revokeObjectURL(elink.href);
    document.body.removeChild(elink);
  }
}
// 获取到点前时间的区间
export function getDateArea(step) {
      var arr = [];
      let myDate = new Date();
      let yy = myDate.getFullYear();
      let mm = myDate.getMonth() + 1;
      let dd = myDate.getDate();
      let nowDate =
        yy + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd);
      let lw = new Date(myDate - 1000 * 60 * 60 * 24 * step);
      let lastY = lw.getFullYear();
      let lastM = lw.getMonth() + 1;
      let lastD = lw.getDate();
      let startdate =
        lastY +
        "-" +
        (lastM < 10 ? "0" + lastM : lastM) +
        "-" +
        (lastD < 10 ? "0" + lastD : lastD);
      arr.push(startdate);
      arr.push(nowDate);
      return arr;
    }
